import "./login.scss"
import BaseCard from "@/components/base-card"
import BaseForm from "@/components/base-form"
import { pageConfig } from "./config/page.config"
import { useState } from "react"
import { Button } from 'antd';
import { useDispatch } from "react-redux"
import { loginAction } from "@/store/modules/login"
import { useNavigate } from "react-router-dom"

const Login = () => {

    const dispatch = useDispatch()
    const navigate = useNavigate()

    const [pageConfigRpe] = useState(pageConfig)

    // 提交
    const submit = (values) => {
        dispatch(loginAction(values, () => {
            navigate("/")
        }))
    }

    return (
        <div className="login">
            <div className="base-card">
                <BaseCard title={"登录"}>
                    <div className="card">
                        <BaseForm config={pageConfigRpe} onSubmit={submit}>
                            <Button type="primary" shape="round" htmlType="submit" size="large" block>
                                登录
                            </Button>
                        </BaseForm>
                    </div>
                </BaseCard>
            </div>
        </div>
    )
}

export default Login